package com.moneywelcome.atomloanassembly.apiimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moneywelcome.atomloanassembly.model.InstalmentRule;
import com.moneywelcome.atomloanassembly.service.InstalmentRuleService;
import com.moneywelcome.atomloanfacade.api.InstalmentRuleApi;
import com.moneywelcome.atomloanfacade.info.InstalmentRuleInfo;
import com.moneywelcome.results.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class InstalmentRuleApiImpl implements InstalmentRuleApi {
    @Autowired
    private InstalmentRuleService instalmentRuleService;
    @Override
    public Result<List<InstalmentRuleInfo>> getRulesByProduct(Integer loanProductId) {
        List<InstalmentRule> rules = instalmentRuleService.list(new QueryWrapper<InstalmentRule>().eq("loan_product_id", loanProductId));

        return null==rules||rules.size()<=0?Result.fail("没有结果"):Result.success(rules);
    }
}
